package com.baichang.taoshunda.dao.impl;

import com.baichang.framework.dao.impl.BaseDaoImpl;
import com.baichang.taoshunda.dao.OrderStateDao;
import com.baichang.taoshunda.entity.OrderStates;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class OrderStateDaoImpl extends BaseDaoImpl<OrderStates> implements OrderStateDao {
    /**
     * 查询订单状态详情
     *
     * @param id
     * @return
     */
    @Override
    public List<Map<String, Object>> getOrderStateDetails(Integer id) {
        String sql = "SELECT order_state,created FROM t_order_state WHERE order_id=?";
        sql += " ORDER BY id DESC";
        return queryForMapList(sql, id);
    }

    @Override
    public int getOrderStateByOrderNumber(int orderId) {
        String sql = "SELECT COUNT(0) FROM t_order_state WHERE order_id=? AND order_state=2";
        return queryForInt(sql);
    }

    @Override
    public int getOrderStateCount(Integer orderNumber, Integer code) {
        String sql = "SELECT COUNT(0)  FROM t_order_state WHERE order_id= ? AND order_state=?";
        return queryForInt(sql, orderNumber, code);
    }

    @Override
    public void updateIsSelfIntroduction(String orderNumber, int i) {
        String sql = "SELECT COUNT(0)  FROM t_order_state WHERE order_id= ? AND order_state=?";
        update(sql, orderNumber, i);
    }


}